﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using RearLivestock.Beginning.Api.Application.hqApplication.Command.Fieldses;
using RearLivestock.Common.Domains.hq;
using RearLivestock.Common.Dtos;
using RearLivestock.RBAC.Api.Application.hqApplication.Commands.Bedroomss;
using RearLivestock.RBAC.Api.Application.hqApplication.Commands.Fieldses;

namespace RearLivestock.RBAC.Api.Controllers.hq
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BedRoomController : ControllerBase
    {
        private readonly IMediator imediator;

        public BedRoomController(IMediator imediator)
        {
            this.imediator = imediator;
        }

        /// <summary>
        /// 栋舍管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> addBedrooms(AddBedroomssComand command)
        {
            return await imediator.Send(command);

        }
        /// <summary>
        /// 栋舍显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<PageResultDto<BedroomDto>>> ShowBedroom(ShowBedroomComand request)
        {
            return await imediator.Send(request);
        }


        /// <summary>
        /// 获取栋舍
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<Bedrooms>> GetDetailBedroom(DetailBedroomsCommand cmd)
        {
            return await imediator.Send(cmd);
        }

        /// <summary>
        /// 栋舍类型
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Handle(GetBedroomTypesCommand cmd)
        {
            return await imediator.Send(cmd);
        }

        /// <summary>
        /// 添加栏位
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddField(CreateFieldCommand cmd)
        {
            return await imediator.Send(cmd);
        }

        /// <summary>
        /// 根据栋舍ID获取栏位
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<List<Fields>>> GetBrdroomIdField(SearchFieldsCommand cmd)
        {
            return await imediator.Send(cmd);
        }

    }
}
